
function build_env_init()
{
    # 安装 X11 开发库（屏幕捕获+键鼠模拟）
    sudo apt-get install libx11-dev libxtst-dev
    # 安装 OpenCV（图像显示+数据处理）
    sudo apt-get install libopencv-dev

    # 安装图片处理库
    sudo apt-get install libjpeg-dev
}

function build_with_opencv()
{
	# low version
	echo "adapting opencv"
	g++ -std=c++11 server.cpp log_manager.cpp -o server.elf `pkg-config --cflags --libs opencv` -lX11 -lXtst -ljpeg -lpthread
	g++ -std=c++11 client.cpp log_manager.cpp -o client.elf `pkg-config --cflags --libs opencv` -lpthread
}

function build_with_opencv4()
{
	# high version
	echo "adapting opencv4"
	g++ -std=c++11 server.cpp log_manager.cpp -o server.elf `pkg-config --cflags --libs opencv4` -lX11 -lXtst -ljpeg -lpthread
	g++ -std=c++11 client.cpp log_manager.cpp -o client.elf `pkg-config --cflags --libs opencv4` -lpthread
}

# usage:
# bash build.sh build_with_opencv
# bash build.sh build_with_opencv4
if [[ $# -lt 1 ]];then 
	echo " "
	echo "usage: "
	echo "    bash build.sh build_with_opencv"
	echo "    bash build.sh build_with_opencv4"
	echo " "
	exit 1;
fi
$@

# 启动服务端
#./server

# 在另一台机器上启动客户端，替换为服务端的局域网IP
#./client 192.168.1.100

